public class Test01 {
    private static int count;
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 10000; i++) {
                synchronized (locker) {
                    count++;
                }
            }
        });
        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 10000; i++) {
                synchronized (locker) {
                    count++;
                }
            }
        });
        t1.start();
        t2.start();
        long start = System.currentTimeMillis();
        t1.join();
        t2.join();
        long end = System.currentTimeMillis();
        System.out.println("count的值为："+count);
        System.out.println("执行时间："+(end-start)+"毫秒");
    }
}
